import pypinyin
from utils.text_utils import is_chinese

def pinyin(word,upper_first_char=True):
    '''
    汉字转拼音
    :param word: 待转换word
    :param upper_first_char: 拼音第一个字符是否大写
    :return:
    '''
    s = ''
    for i in pypinyin.lazy_pinyin(word, style=pypinyin.NORMAL):
        if upper_first_char:
            s += ''.join(i.capitalize())
        else:
            s += ''.join(i)
    return s



def conver_word_zh(slot_value,slot_type):
    if is_chinese(slot_value):
        if slot_type == "LastName":
            slot_value = pinyin(slot_value)
    return slot_value

if __name__ == '__main__':
    pass